import Vue from 'vue'
import Router from 'vue-router'

//组件模块
import explain from './components/Explain'
import article from './components/Article'
import add from './components/Add'
 
Vue.use(Router)
var axios = require('axios')
axios.defaults.timeout = 5000
// axios.defaults.baseURL = '/api'
Vue.prototype.$axios = axios
/**
 * 重写路由的push方法
 */
const routerPush = Router.prototype.push
Router.prototype.push = function push(location) {
  return routerPush.call(this, location).catch(error=> error)
}

export default new Router({
  routes: [
    { name: 'home', path: '/', component: explain },
    { name: 'explain', path: '/explain', component: explain },
    { name: 'article', path: '/article', component: article},
    { name: 'add',path: '/add', component: add}
  ],
  use_query_string: true
})

